<%--
  Created by IntelliJ IDEA.
  User: LT
  Date: 2018-11-27
  Time: 8:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <jsp:include page="${pageContext.request.contextPath}/common/common.jsp"></jsp:include>
</head>
<body>
<!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    //loading区
     myChart.showLoading();
    $.post("/house/queryGroupType",function (data) {

        //隐藏loading
        myChart.hideLoading();
        var tnames = [] ;
        var tcount = [] ;

        $.each(data.t,function (index,item) {
            tnames.push(item.dianpu_Name) ;
        })

        $.each(data.t,function (index,item) {
            var v = {name:item.dianpu_Name,value:item.dianpu_NameCount} ;
            tcount.push(v) ;
        })

        console.log(tnames +"---"+ tcount)
     //隐藏loading
        myChart.hideLoading();
        myChart.setOption({
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)"
            },
            toolbox: {          //图表容器的右上角工具栏
                feature: {
                    dataView: {show: true, readOnly: false},
                    magicType: {show: true, type: ['line', 'bar']},
                    restore: {show: true},
                    saveAsImage: {show: true}
                }
            },
            legend: {
                orient: 'vertical',
                x: 'left',
                data:tnames
            },
            series: [
                {
                    name:'访问来源',
                    type:'pie',
                    radius: ['50%', '70%'],
                    avoidLabelOverlap: false,
                    label: {
                        normal: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            show: true,
                            textStyle: {
                                fontSize: '30',
                                fontWeight: 'bold'
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            show: false
                        }
                    },
                    data: tcount
                }
            ]
        });

    })
</script>
</body>
</html>
